#include<iostream>

double Polynomial(double x, double a[], int n) {
    double cur = 1;
    double sum = 0;
    for (int i = 0; i <= n ; i++) {
        sum += (cur * a[i]);
        cur *= x;
    }
    return sum;
} 

int main() {
    int n = 3;
    double a[] = {1, 2, 3, 4, 5, 6, 7, 8};
    for (int i = -3; i <= 3; ++i) {
        std::cout << Polynomial(i, a, 7) << std::endl;
    }
    return 0;
}
